<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Language" content="zh-CN">
    <head>
      

    <link rel="stylesheet" type="text/css" href="../assets/css/main.css" />
    <script type="text/javascript" src="../assets/js/jquery1.42.min.js"></script>
    <script type="text/javascript" src="../assets/js/jquery.SuperSlide.2.1.js"></script>
        <title>Synopsys Toaster Master Club Message Wall</title>
	</head>

    <body style="background: url(../assets/images/bg.jpg) no-repeat left top; background-size:100% 100%;">
        <div class="snps_title">
            <h3 style="font-size: 30px;padding:-30px">Synopsys TMC 200<sup>th</sup> Meeting Message Wall <button class="btn btn-danger draw" style="margin-top:5px;float:right">Lucky Draw</button></h3>
        
	</div>
    
        <div class="drawp" style="height:250px;display:none;">
            <div class="text-center" style="padding-top:10px;"><button class="btn text-center" id="start">Start</button> <input type="text" value=1 id='val' style="height:28px;width:28px;font-size:18px"></div>
            <div class="am-panel-bd am-collapse am-in am-cf" id="collapse-panel-3">
            <ul class="text-center" style="height:60px;padding-top:2px;" id="dt">
               <li style='font-size:40px;padding:10px'>Congratulation!</li>
			</ul>
            
		</div>            
		</div>	

 
	<div class="txtMarquee-top">
		<div class="am-panel-bd am-collapse am-in am-cf" id="collapse-panel-3">
			<ul class="am-comments-list admin-content-comment" id="main">
               
			</ul>
		</div>
	</div>

    

    <?php 
		$admin =  isset($_GET['admin']) ? $_GET['admin'] :0;
	?>

	<script type="text/javascript">			
        $(document).ready(function() {		
        	var admin = <?php echo $admin; ?>;
            
            function getData() {
            	
           		  $.ajax({
                 type : 'POST',
                 url : 'ajax_add.php',
                 dataType : 'json',
                 data : {
                     admin: admin
                 },
                 success : function(resJson, textStatus){
                     var len = resJson.reta.length;
                     var strout = "";
                     for(var i=0; i<len; i++) {
                         if(admin == '1' && resJson.reta[i].is_check == '0') {
                         strout = strout + "<li class='am-comment'><a href='#'><img   \
                   					 src='../assets/images/" + Math.ceil(Math.random()*1000%40)+".jpg' alt=''  \
									 class='am-comment-avatar' width='48' height='48'>  \
									</a>   \
                                    <div class='am-comment-main'>  \
                                        <header class='am-comment-hd'>   \
                                            <div class='am-comment-meta'>   \
                                                <a href='#' class='am-comment-author'>"+resJson.reta[i].cellphone.replace(resJson.reta[i].cellphone.substring(3,7),'****')+ "</a> 评论于  \
                                                <time>" + resJson.reta[i].date + "</time>";
                                                
                                                    strout = strout  + "<a class='btn btn-default'  id='deploy' style='float:right' data_id='"+resJson.reta[i].id+"'>发布</a>";
                                                                         	
                           
                                 strout = strout + "</div>  \
                                        </header>  \
                                        <div class='am-comment-bd'>  \
                                            <p>" + resJson.reta[i].comment + "</p>  \
                                        </div>   \
                                    </div>  \
                                </li>  \
						";
                         } else if(resJson.reta[i].is_check == '1'){
                             strout = strout + "<li class='am-comment'><a href='#'><img   \
                   					 src='../assets/images/" + Math.ceil(Math.random()*1000%40)+".jpg' alt=''  \
									 class='am-comment-avatar' width='48' height='48'>  \
									</a>   \
                                    <div class='am-comment-main'>  \
                                        <header class='am-comment-hd'>   \
                                            <div class='am-comment-meta'>   \
                                                <a href='#' class='am-comment-author'>"+resJson.reta[i].cellphone.replace(resJson.reta[i].cellphone.substring(3,7),'****')+ "</a> 评论于  \
                                                <time>" + resJson.reta[i].date + "</time>";
                                                if(admin == '1' && resJson.reta[i].is_check == '0'&& $_SESSION["admin"] =="1") {
                                                    strout = strout  + "<a class='btn btn-default'  id='deploy' style='float:right' data_id='"+resJson.reta[i].id+"'>发布</a>";
                                                }                         	
                           
                                 strout = strout + "</div>  \
                                        </header>  \
                                        <div class='am-comment-bd'>  \
                                            <p>" + resJson.reta[i].comment + "</p>  \
                                        </div>   \
                                    </div>  \
                                </li>  \
						";
                         }
                     }

                     $("#main").html(strout);
                     if(admin == "0") {
                     $(".txtMarquee-top").slide({mainCell:".am-panel-bd ul",autoPlay:true,effect:"topMarquee",vis:7,interTime:10});
                     }
                     
                     $("#deploy").each(function() {
                         $(this).click(function() {
                            id = $(this).attr('data_id');
                         	$.ajax({
                                 type : 'POST',
                                 url : 'ajax_update.php',
                                 dataType : 'json',
                                 data : {
                                     id: id
                                 },
                                 success : function(resJson, textStatus){
                                     alert(resJson.msg);
                                     if(resJson.status=="success") {
                                         window.location.reload();
                                     }
                                 }
                            });
                         
                        });
                     });
                 },
                 error : function(XMLHttpRequest, textStatus, errorThrown) {
                 	return false;
                 }
             });
            }
            
            getData();
                         
            // setInterval(getData,1000*10);
            $(".draw").click(function(){
  				$(".drawp").toggle();
            });
            
            
          
            var flag = 0;
            Array.prototype.unique2 = function()
            {
                var n = {},r=[]; //n为hash表，r为临时数组
                for(var i = 0; i < this.length; i++) //遍历当前数组
                {
                    if (!n[this[i]]) //如果hash表中没有当前项
                    {
                        n[this[i]] = true; //存入hash表
                        r.push(this[i]); //把当前数组的当前项push到临时数组里面
                    }
                }
                return r;
            }
            $("#start").click(function(){
                
                               
                if($("#start").text() == "Start" && flag == 0) {
                    $("#start").text("Stop");
                    flag = 1;
                    $.ajax({
                        type : 'POST',
                        url : 'ajax_add.php',
                        dataType : 'json',
                        data : {
                           
                        },
                        success : function(resJson, textStatus){
                            
                             var len = resJson.reta.length;
                             var strout = "";
                             for(var i=0; i<len; i++) {
                                strout = strout + "<li style='font-size:40px;padding:10px'>" + resJson.reta[i].cellphone + "</li>";
                             } 
                            $("#dt").html(strout);
            
                            $(".drawp").slide({mainCell:".am-panel-bd ul",autoPage:true,effect:"top",autoPlay:true,vis:$('#val').val(),delayTime:0,interTime:10,mouseOverStop:false,playStateCell:"#start"});
                        }
                    
                    });
                } else {
                    if($("#start").text() == "Start") {
                     $("#start").text("Stop");
                    } else {
                        $("#start").text("Start");
                    }
                    //$("#dt").html("");	
                }
            	
            });
            
           
            
        });
        
		
        
	</script>

</body>
</html>
